package interview;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;

/**
 * Created by QingYun on 2017/10/18.
 */
public class BaiduTest {


    public static void main(String[] args) {
        try {
            Scanner scanner = new Scanner(System.in);
            int total = scanner.nextInt();
            if (total <= 50 && total > 0) {
                List<Integer> list = new ArrayList<>();
                Scanner sc = new Scanner(System.in);
                List<Integer> smallLeast = new ArrayList<>();
                for (int i = 0; i < 10; i++) {
                    int a=sc.nextInt();
                    list.add(a);
                }
//            for (String s : strings) {
//                if (!s.equals("")) {
//                    try {
//                        int a = Integer.valueOf(s);
//                        list.add(a);
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//            //
                //
                removeDuplicate((ArrayList) list);
                try {
                    for (int i = 0; i < 3; i++) {

                        int first = list.get(0);
                        for (Integer a : list) {
                            if (a <first) {
                                first = a;
                            }
                        }
                        int index=list.indexOf(first);
                        list.remove(index);
                        smallLeast.add(first);
                    }
                    if (smallLeast.size() == 3) {
                        System.out.println(smallLeast.get(2));
                    } else {
                        System.out.println(-1);
                    }
                }catch (Exception e){
                    System.out.println(-1);
                }

            }else {
                System.out.println(-1);
            }
        }catch (Exception e){

        }

    }
    public static void removeDuplicate(ArrayList arlList)
    {
        HashSet h = new HashSet(arlList);
        arlList.clear();
        arlList.addAll(h);
    }



}



